<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            border: 10px solid red;
            margin: 40px auto;
            height: 50px;
        }
        .a{
            width: 0;
            height: 50px;
            background-color: green;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="a"></div>
        <p>0%</p>
    </div>

    <script>

        var oBox = document.querySelector('.box') ;
        var oA = document.querySelector('.a') ;
        var oP = document.querySelector('p') ;
        var max = oBox.clientWidth ;
        var w = max / 100 ;

        var i = 0 ; 
        var t = setInterval(function() {
            i++ ;
            oA.style.width = i * w + 'px' ;
            oP.innerHTML = i + '%' ;
            if(i === 100) {
                clearInterval(t)
            }
        } , 10)
  

    </script>
    
</body>
</html>